package com.tungse.study.rpc;


import com.tungse.study.rpc.domain.ProducerUser;
import com.tungse.study.rpc.framework.LoadBalance;
import com.tungse.study.rpc.framework.entity.RpcUri;
import com.tungse.study.rpc.framework.register.RemoteMapRegister;
import com.tungse.study.rpc.service.ProducerService;
import com.tungse.study.rpc.framework.RpcProxy;
import org.junit.Test;

import java.util.List;

/**
 * @author Tungse
 */
public class ConsumerApplication {
    public static void main(String[] args) {


        ProducerService producerService = RpcProxy.createProxy(ProducerService.class);
//        String lisi = new ObjectMapper().writeValueAsString(producerService.getUser("aaaaalisi"));
//        System.out.println(lisi);

        producerService.saveUser(new ProducerUser("saveUser_test", 118));


    }


    @Test
    public void test() {
        RemoteMapRegister.register(ProducerService.class.getName(), new RpcUri("127.0.0.1",8081));

        List<RpcUri> serviceUri = RemoteMapRegister.getServiceUri(ProducerService.class.getName());
        RpcUri rpcUri = LoadBalance.getServiceUri(serviceUri);
        System.out.println(rpcUri);
    }
}
